# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py3-py
pkgver=1.10.0
pkgrel=2
pkgdesc="Python3 library with cross-python path, ini-parsing, io, code, log facilities"
url="https://py.readthedocs.io"
arch="noarch"
license="MIT"
depends="python3"
makedepends="py3-setuptools"
source="https://files.pythonhosted.org/packages/source/p/py/py-$pkgver.tar.gz
	0001-remove-setuptools_scm.patch
	"
options="!check" # Broken
builddir="$srcdir/py-$pkgver"

replaces="py-py" # Backwards compatibility
provides="py-py=$pkgver-r$pkgrel" # Backwards compatibility

prepare() {
	default_prepare

	# Split version into semver variables
	local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'
	_major=$(echo "$pkgver" | sed -e "s/$RE/\1/")
	_minor=$(echo "$pkgver" | sed -e "s/$RE/\2/")
	_patch=$(echo "$pkgver" | sed -e "s/$RE/\3/")

	echo "version = '$pkgver'" > py/_version.py
	echo "version_tuple = ($_major, $_minor, $_patch)" >> py/_version.py
}

build() {
	python3 setup.py build
}

check() {
	python3 setup.py test
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir"
}

sha512sums="7a0eb964067bc01fa4f8ffe70b043abfd4619134fbee2935713e28382085d0b8972c319ed665a643b879b18ce662db8a9bd722937af7cf36c233214eea211dd1  py-1.10.0.tar.gz
387457b20851c86a4e5198eb9c43ddf3ab8e4a9461a2b1ff7cd3813ce4f713769e08a2e1ce15901b7762f6fd0863d1736ffc7733673f251470653000f678f43b  0001-remove-setuptools_scm.patch"
